package cn.echoedu.control;

import static cn.echoedu.constants.AuthorityCode.ADD_CLASS_NOTIFY;
import static cn.echoedu.constants.AuthorityCode.ADD_SCHOOL_NOTIFY;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.echoedu.entity.JobAuthority;
import cn.echoedu.entity.receivecommand.MonitorAddNotifyReceive;
import cn.echoedu.entity.receivecommand.TeacherAddNotifyReceive;
public class AuthorityControl extends BaseControl{
    
	public boolean validateTeacherAddNotify(HttpServletRequest request,
			HttpServletResponse response,
			TeacherAddNotifyReceive teacheraddnotifyreceive) {
		// TODO Auto-generated method stub
		List<JobAuthority> jobauthoritylist = getJobAuthorityModel()
				.queryByJobCode(teacheraddnotifyreceive.getJobcode());
		for(JobAuthority jobauthority:jobauthoritylist){
			if(canAddNotify(jobauthority)){
				return true;
			}
		}
		return false;
	}
	private boolean canAddNotify(JobAuthority jobauthority){
	 	return ADD_SCHOOL_NOTIFY==jobauthority.getAuthority().getAuthoritycode();
	 }
	public boolean validateMonitorAddNotify(HttpServletRequest request,
			HttpServletResponse response,
			MonitorAddNotifyReceive monitoraddnotifyreceive) {
		// TODO Auto-generated method stub
		List<JobAuthority> jobauthoritylist = getJobAuthorityModel()
				.queryByJobCodeAndAuthoritycode(monitoraddnotifyreceive.getJobcode()
						,ADD_CLASS_NOTIFY);
		 if(jobauthoritylist!=null&&jobauthoritylist.size()>0){
			 return true;
		 }
		
		return false;
	}

}
